package com.shangcheng.server.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
import com.shangcheng.model.domain.OmsOrderSetting;
import com.shangcheng.model.vo.result.Result;
import com.shangcheng.server.service.OmsOrderSettingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

/**
 * @author maorf
 * @version 1.0
 */
@RestController
@RequestMapping("orderSetting")
public class OmsOrderSettingController {
    @Autowired
    private OmsOrderSettingService omsOrderSettingService;

    //修改指定订单设置
    @PostMapping("update/{id}")
    public ResponseEntity updateById(@PathVariable Integer id, @RequestBody OmsOrderSetting omsOrderSetting){
        omsOrderSetting.setId(Long.valueOf(id));
        omsOrderSettingService.updateById(omsOrderSetting);
        return ResponseEntity.ok(new Result(200,null,null));
    }


    //获取指定订单设置
    @GetMapping("/{id}")
    public ResponseEntity getById(@PathVariable Integer id){
        OmsOrderSetting one = omsOrderSettingService.getOne(new LambdaQueryWrapper<OmsOrderSetting>().eq(OmsOrderSetting::getId, id));
        return ResponseEntity.ok(new Result(200,one,null));
    }
}
